Require evidence for ban, tempban, and kick moderation actions#188
Merged
Conversation
… validate evidence input and handle missing evidence cases. Adjusted related tests to ensure proper functionality and error handling.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #188 +/- ##
==========================================
+ Coverage 65.18% 65.36% +0.18%
==========================================
Files 52 52
Lines 3056 3069 +13
==========================================
+ Hits 1992 2006 +14
+ Misses 1064 1063 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enforces that moderation actions (ban/tempban/kick and platform account_banned webhook bans) include non-empty evidence/notes to support auditability and moderation review.
Changes:
- Makes
evidencea required slash-command argument for/ban,/tempban, and/kick, and validates blank/whitespace-only evidence. - Adds webhook-side validation requiring non-empty
notesforACCOUNT_BANNEDevents and uses those notes as ban evidence. - Adds/updates unit tests covering missing/blank evidence/notes across commands, helpers, and webhook handlers.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/src/webhooks/handlers/test_base.py | Adds unit tests for new non-empty string validation helper. |
| tests/src/webhooks/handlers/test_account.py | Adds coverage that ACCOUNT_BANNED rejects missing notes. |
| tests/src/helpers/test_ban.py | Adds coverage for rejecting blank evidence in ban helper logic. |
| tests/src/cmds/core/test_user.py | Updates kick tests for required evidence and adds blank-evidence rejection test. |
| src/webhooks/handlers/base.py | Introduces validate_non_empty_string() for webhook payload validation. |
| src/webhooks/handlers/account.py | Requires non-empty notes for account bans and passes notes as evidence. |
| src/helpers/ban.py | Adds shared validate_evidence() and removes fallback evidence behavior. |
| src/cmds/core/user.py | Makes kick evidence required and validates evidence before kicking. |
| src/cmds/core/ban.py | Makes ban/tempban evidence required in command signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that apply.Proposed changes
Moderation actions now require non-empty evidence across Discord commands and platform ban webhooks.
evidencea required parameter on/ban,/tempban, and/kickvalidate_evidence()validation and reject blank or whitespace-only values"none provided"fallback when banning through the helper layernotesfor platformaccount_bannedwebhook events (HTTP 400 when missing)This ensures every ban or kick is backed by documented evidence for moderation review and audit trails.
Checklist
Put an
xin the boxes that apply.doc.
Additional context
Platform integrations sending
account_bannedevents must include a non-emptynotesfield. Moderators using slash commands must provide evidence when issuing bans or kicks.